import Vue from 'vue'
import Vuex from '../vuex'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    count: 0
  },
  getters: {
    getCount(state) {
      return state.count
    }
  },
  mutations: {
    add(state, payload) {
      state.count += payload
    }
  },
  actions: {
    add({ commit }, payload) {
      commit('add', payload)
    }
  },
  modules: {
    namespace: true,
    my: {
      state: {
        num: 0
      },
      getters: {
        getNumber(state) {
          return state.my.num
        }
      },
      mutations: {
        add(state, payload) {
          state.my.num += payload
        }
      },
      actions: {
        add({ commit }, payload) {
          commit('/my/add', payload)
        }
      }
    }
  }
})
